import SingtonClass from "./SingleClass";
/**
 * 舞台工具类
 */
export default class StageUtils extends SingtonClass {
    public constructor() {
        super();

        cc.game.on(cc.game.EVENT_HIDE, this.hide, this);//隐藏
        cc.game.on(cc.game.EVENT_SHOW, this.show, this);//显示
    }

    public static getInstance<StageUtils>(): StageUtils {
        return super.getInstance() as StageUtils;
    }

    /**
    * 获取当前游戏窗口高度
    * @returns {number}
    */
    public getHeight(): number {
        return cc.winSize.height;
    }

    /**
     * 获取当前游戏窗口宽度
     * @returns {number}
     */
    public getWidth(): number {
        return cc.winSize.width;
    }

    /**
    * 获取当前Canvas
    * @returns {cc.Canvas}
    */
    public getStage(): cc.Canvas {
        return cc.Canvas.instance;
    }

    /**
     * 适配高度模式
     */
    public setFitHeight() {
        const canvas = this.getStage();
        canvas.fitHeight = true;
        canvas.fitWidth = false;
    }

    /**
     * 适配宽度模式
     */
    public setFitWidth() {
        const canvas = this.getStage();
        canvas.fitHeight = false;
        canvas.fitWidth = true;
    }


    /**
     * 设置帧率
     * @param value
     */
    public setFrameRate(value: number = 60): void {
        cc.game.setFrameRate(value);
    }

    /**获取帧率 */
    public getFrameRate(): number {
        return cc.game.getFrameRate();
    }


    /**暂停游戏 */
    public pause(): void {
        cc.game.pause();
    }

    /**恢复游戏 */
    public resume(): void {
        cc.game.resume();
    }

    hide() {

    }

    show() {
    }

}